﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HomeCareLibrary.Core.Dtos;
using HomeCareLibrary.DataAccess;

namespace HomeCareLibrary.AppService.Mappers
{
    /// <summary>
    /// 
    /// </summary>
    static partial class Benefit_Icon_UrlsMapper
    {
        /// <summary>
        /// Invoked when <see cref="ToDTO"/> operation is about to return.
        /// </summary>
        /// <param name="dto"><see cref="Benefit_Icon_UrlsDto"/> converted from <see cref="Benefit_Icon_Urls"/>.</param>
        static partial void OnDTO(this Benefit_Icon_Urls entity, Benefit_Icon_UrlsDto dto);

        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Benefit_Icon_Urls"/> converted from <see cref="Benefit_Icon_UrlsDto"/>.</param>
        static partial void OnEntity(this Benefit_Icon_UrlsDto dto, Benefit_Icon_Urls entity);

        /// <summary>
        /// Converts this instance of <see cref="Benefit_Icon_UrlsDto"/> to an instance of <see cref="Benefit_Icon_Urls"/>.
        /// </summary>
        /// <param name="dto"><see cref="Benefit_Icon_UrlsDto"/> to convert.</param>
        public static Benefit_Icon_Urls ToEntity(this Benefit_Icon_UrlsDto dto)
        {
            if (dto == null) return null;

            var entity = new Benefit_Icon_Urls();

            entity.benefit = dto.benefit;
            entity.benefit_name = dto.benefit_name;
            entity.ben_icon_url = dto.ben_icon_url;

            dto.OnEntity(entity);

            return entity;
        }

        /// <summary>
        /// Converts this instance of <see cref="Benefit_Icon_Urls"/> to an instance of <see cref="Benefit_Icon_UrlsDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="Benefit_Icon_Urls"/> to convert.</param>
        public static Benefit_Icon_UrlsDto ToDTO(this Benefit_Icon_Urls entity)
        {
            if (entity == null) return null;

            var dto = new Benefit_Icon_UrlsDto();

            dto.benefit = entity.benefit;
            dto.benefit_name = entity.benefit_name;
            dto.ben_icon_url = entity.ben_icon_url;

            entity.OnDTO(dto);

            return dto;
        }

        /// <summary>
        /// Converts each instance of <see cref="Benefit_Icon_UrlsDto"/> to an instance of <see cref="Benefit_Icon_Urls"/>.
        /// </summary>
        /// <param name="dtos"></param>
        /// <returns></returns>
        public static List<Benefit_Icon_Urls> ToEntities(this IEnumerable<Benefit_Icon_UrlsDto> dtos)
        {
            if (dtos == null) return null;

            return dtos.Select(e => e.ToEntity()).ToList();
        }

        /// <summary>
        /// Converts each instance of <see cref="Benefit_Icon_Urls"/> to an instance of <see cref="Benefit_Icon_UrlsDto"/>.
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public static List<Benefit_Icon_UrlsDto> ToDTOs(this IEnumerable<Benefit_Icon_Urls> entities)
        {
            if (entities == null) return null;

            return entities.Select(e => e.ToDTO()).ToList();
        }
    }
}
